package YOOTK;
import java.io.*;
import java.net.*;
public class HelloServer {
    public static void main(String[] args) throws Exception {
        // 9999端口绑定监听
        ServerSocket serverSocket = new ServerSocket(9999);
        System.out.println("[HelloServer] 服务端启动监听......");

        // 每个连接到服务端的客户端都通过Socket对象来描述
        Socket client = serverSocket.accept();
        System.out.println("[HelloServer] 客户端连接成功......");

        // 向指定的socket实现数据的输出，所以应该获取socket输出流
        PrintStream out = new PrintStream(client.getOutputStream());
        out.println("www.yootk.com");

        // 等待数据发送完毕
        client.shutdownOutput();
        // 服务端关闭
        serverSocket.close();
    }
}
